home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 12 < prev    next >
Internet Message Format  |  1996-08-06  |  2KB

  1. Path: rz.uni-karlsruhe.de!not-for-mail
  2. From: ig25@fg70.rz.uni-karlsruhe.de (Thomas Koenig)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Alignment of malloc()
  5. Date: 2 Jan 1996 23:25:47 +0100
  6. Organization: =?ISO-8859-1?Q?Universit=E4t_Karlsruhe_(TH),_Germany_?=
  7. Message-ID: <4ccbdb$5v6@fg70.rz.uni-karlsruhe.de>
  8. References: <DKDA7D.Kw7@midway.uchicago.edu> <j66Sx*FRe@yaps.rhein.de> <DKKHCH.L6r@midway.uchicago.edu>
  9. Reply-To: ig25@mvmap66.ciw.uni-karlsruhe.de
  10. NNTP-Posting-Host: fg70.rz.uni-karlsruhe.de
  11. Mime-Version: 1.0
  12. Content-Type: text/plain; charset=iso-8859-1
  13. Content-Transfer-Encoding: 8bit
  14. NNTP-Posting-User: ig25
  15.  
  16. In comp.std.c, Michael Spertus<mps@geodesic.com> wrote:
  17.  
  18. >My question is what the committee means by the words "proper alignment". If
  19. >"proper" COMPLETELY ignores efficiency consideration even if they are
  20. >gross, it means that I would have to align all malloc() returns according to
  21. >the size of the data in all portable code I write.
  22.  
  23. This is a quality of implementation issue.  In other words, somebody
  24. could write a losing compiler/standard library which generated pessimal
  25. code when malloc() is used with certain data types.  A compiler writer
  26. is also allowed to have the compiler put a loop eating up 100 seconds of
  27. CPU time each time an assignment is made.  Neither would tend to sell
  28. many compilers; neither is likely to be implemented.
  29.  
  30.  
  31. >However, I've never seen
  32. >an "ANSI C" textbook that advises aligning malloc() returns by hand.
  33.  
  34. I know of no compiler which is as brain-damaged as the one you describe;
  35. when I encounter one, I'd tend to howl to the vendor.
  36. -- 
  37. Thomas Koenig, Thomas.Koenig@ciw.uni-karlsruhe.de, ig25@dkauni2.bitnet.
  38. The joy of engineering is to find a straight line on a double
  39. logarithmic diagram.
  40.